home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
ask3.zip
/
ASK3EG.BAT
< prev
next >
Wrap
DOS Batch File
|
1986-12-11
|
3KB
|
105 lines
echo off
:home
echo.
echo This is a batch file to demonstrate how to use ASK.
rem *** EXAMPLE #1
echo -----------------------------------------------------------------------
echo First, a trival example:
ask "Hit a key when ready .."
rem *** EXAMPLE #2
echo -----------------------------------------------------------------------
echo Now, a simple example:
ask "Is there a cat in your house (press Y or N)? " yn
if errorlevel 2 goto dont
echo Good! Some day I'll have to come visit your cat.
goto eg3
:dont
echo You don't? If you like, you can come visit the cat in my house.
rem *** EXAMPLE #3
:eg3
echo -----------------------------------------------------------------------
echo You can create a menu with ASK:
echo [F1] Hamburger
echo [F2] Chicken Haha King
echo [F3] Toss Salad
echo.
ask "May I take your order? " ~(f1)~(f2)~(f3)
if errorlevel 3 goto toss
if errorlevel 2 goto chicken
echo Here's your Hamburger. Enjoy your sandwitch.
goto eg4
:chicken
echo Here's your Chicken Haha King. Ha ha.
goto eg4
:toss
echo Your salad is tossed.
:eg4
echo -----------------------------------------------------------------------
echo Now an advance example showing the timeout feature:
echo Suppose there's a time bomb in this batch file and and is set to go
echo off in 10 seconds, and you have the following choices:
echo R) Run
echo r) Reboot
echo T) Try to disarm it
rem *** make response case sensitive to make it harder
ask/fcs10 "What would you do (press R/r/T)? " RrT
if errorlevel 255 goto bomb
if errorlevel 3 goto disarm
if errorlevel 2 goto boot
rem *** run. Note the use of ask with timeout=0 (default) as an echo command.
rem *** You can echo control characters this way.
echo Running...
ask/s "\7You had run ten feet when the bomb exploded.~m~j"
echo Now you're at 100 feet!
goto folks
:boot
echo That would have worked, but you should use ctrl-alt-del to reboot.
echo Anyway, you got blasted.
goto folks
:disarm
echo Disarming...
echo You succeeded in disarming the bomb. Congratulation.
goto folks
:bomb
echo *CLICK* ! ! ! B O O M ! ! !
rem *** use ask to print control characters (bells in this case)
ask/s \7\7\7
echo You're too slow. The timer made a home run and you're out.
goto folks
:folks
echo -----------------------------------------------------------------------
rem *** do ansi.sys demo
ask/fs0 \e[6n~m
if errorlevel 27 goto ansi
echo If you have installed the ANSI.SYS driver I can show you how to
echo change screen attribute with ASK. But you don't. Oh well.
goto nomore
:ansi
ask/fs "You can use ASK to change screen attributes:~m~j"
ask/s "\e[5mBlink \e[7mReverse video \e[32mColor maybe? \e[0m~m~j"
:nomore
echo That's the end of the ASK demo.
rem *** actually not, this is another one.
rem *** show the no echo option
echo If you want to run this demo again, press the (Home) key; otherwise
ask/eq "press the (End) key to return to DOS." ~(end)~(home)
:loop
if errorlevel 2 goto home
if errorlevel 1 goto dos
ask/eq "\7" ~(end)~(home)
goto loop
:dos
echo.